翻訳と辞書
Words near each other
・ Butaleja District
・ Butallylonal
・ Butalmapu
・ Butam language
・ Butamalal River
・ Busy line interrupt
・ Busy Little Bears
・ Busy Man
・ Busy Monsters
・ Busy override
・ Busy Philipps
・ Busy Signal
・ Busy signal
・ Busy signal (disambiguation)
・ Busy verification
Busy waiting
・ Busy work
・ Busy, Doubs
・ Busy, Kentucky
・ Busy-hour call attempts
・ Busybody
・ Busybody (horse)
・ Busybody Nora
・ BusyBox
・ Busycon
・ Busycon contrarium
・ Busyconinae
・ Busycotypus
・ BusyInternet
・ Busytown


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Busy waiting : ウィキペディア英語版
Busy waiting
In software engineering, busy-waiting, busy-looping or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as whether keyboard input or a lock is available. Spinning can also be used to generate an arbitrary time delay, a technique that was necessary on systems that lacked a method of waiting a specific length of time. Processor speeds vary greatly from computer to computer, especially as some processors are designed to dynamically adjust speed based on external factors, such as the load on the operating system. As such, spinning as a time delay technique often produces unpredictable or even inconsistent results unless code is implemented to determine how quickly the processor can execute a "do nothing" loop, or the looping code explicitly checks a real-time clock.
Spinning can be a valid strategy in certain circumstances, most notably in the implementation of spinlocks within operating systems designed to run on SMP systems. In general, however, spinning is considered an anti-pattern and should be avoided,〔http://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt〕 as processor time that could be used to execute a different task is instead wasted on useless activity.
==Example C code==
The following C code examples illustrate two threads that share a global integer i. The first thread uses busy-waiting to check for a change in the value of i:

#include
#include
#include
#include

volatile int i = 0; /
* i is global, so it is visible to all functions.
It's also marked volatile, because it
may change in a way which is not predictable by the compiler,
here from a different thread.
*/

/
* f1 uses a spinlock to wait for i to change from 0.
*/
static void
*f1(void
*p)
static void
*f2(void
*p)
int main()

pthread_join(t1, NULL);
pthread_join(t2, NULL);
puts("All pthreads finished.");
return 0;
}

In a use case like this, one can consider using C11's condition variables.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Busy waiting」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.